//
function request(num) {
  // 模拟接口请求
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(num * 2)
    }, 1000)
  })
}

request(1).then((res1) => {
  console.log(res1) // 1秒后 输出 2

  request(2).then((res2) => {
    console.log(res2) // 2秒后 输出 4

    request(2).then((res2) => {
      console.log(res2) // 2秒后 输出 4

      request(2).then((res2) => {
        console.log(res2) // 2秒后 输出 4

        request(2).then((res2) => {
          console.log(res2) // 2秒后 输出 4
        })
      })
    })
  })
})

async function fn() {
  const res1 = await request(5)
  const res2 = await request(res1)
  const res2 = await request(res1)
  const res2 = await request(res1)
  const res2 = await request(res1)
  const res2 = await request(res1)

  console.log(res2) // 2秒后输出 20

  return res2
}
fn().then((res) => {})
